<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script  runat="server">
Dim TotalRecords=0,TotalPages=0
Dim Records=5
Sub Page_Load(ByVal sender As Object, _
	ByVal e As EventArgs)
	BindGrid()
End Sub
Sub MyDataGridPage(sender As Object, e As _
	DataGridPageChangedEventArgs) 
	DataResult.CurrentPageIndex = e.NewPageIndex		
	BindGrid	
End Sub
Private Sub BindGrid()		
	DataResult.PageSize=Records		 
	Dim strSQL = "select * from Employees"
	Dim myConnection As SqlConnection = _
	New SqlConnection("server=localhost;uid=sa;pwd=;database=Northwind")	
	dim myAdapter as SqlDataAdapter = _
	New SqlDataAdapter(strSQL, myConnection)
	dim myDataSet as DataSet = New DataSet()		
	myAdapter.Fill(myDataSet,strSQL)	
	DataResult.DataSource=myDataSet
	DataResult.DataBind()
End Sub
</script>
<html>
<head>
<title>DataGrid Control</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<h2>DataGrid and Paging</h2>
<form runat=server>
                   <table width="100%" border="0" cellpadding="0" cellspacing="0">
                      <tr> 
                        <td >          
                          <asp:DataGrid  
		ID="DataResult"			
		AutoGenerateColumns="False" runat="server" > <Columns> 
                          	<asp:TemplateColumn HeaderText="EmployeeID"> <ItemTemplate> 
                          	<asp:Label ID="EmployeeID" Text=<%# "<a href='abc.aspx?id=" + DataBinder.Eval(Container.DataItem, "EmployeeID").toString() + "'>" + DataBinder.Eval(Container.DataItem, "FirstName").toString() + "</a>"%> Runat=server /> 
                          	</ItemTemplate> </asp:TemplateColumn>
		<asp:TemplateColumn HeaderText="Name"> <ItemTemplate> 
                          	<asp:Label ID="Name" Text=<%# DataBinder.Eval(Container.DataItem, "LastName").toString() %> Runat=server /> 
                          	</ItemTemplate> </asp:TemplateColumn>
		</Columns> </asp:DataGrid> 
                        </td>
                      </tr>
                </table>
</form>
</body>
</html>
